/**
	MenuItem class. Creates Menu items with highlighted states for a Flash Lite 2 application
 */
 
//****************************************************************************
//Copyright (C) 2005 Adobe Systems, Inc. All Rights Reserved.
//The following is Sample Code and is subject to all restrictions on
//such code as contained in the End User License Agreement accompanying
//this product.
//****************************************************************************

class MenuItem {
	private var menuItem_mc:MovieClip;
	// used to store menu item movieClip instance
	private var classInstance:String;
	// used to store this class' instance name
	private var viewer:Object;
	// used to store class instance of media viewer
	private var $mime:String;
	// used to store the long form MIME type to check
	/**
	 * MenuItem Constructor
	 * 
	 * @param menuLabel		the text label for the menu item
	 * @param xPos			the x position to place the menu item at
	 * @param yPos			the y position to place the menu item at
	 * @param classType		the class type we want to make a new instance of
	 * @param mediaURL		the URL of the new media we want to load in the new class instance
	 * @param target			the main menu clip to create our new menu item clip in
	 * @param depth			the depth of our new menu item clip
	 */
	public function MenuItem (menuLabel:String, xPos:Number, yPos:Number, target:MovieClip, depth:Number) {
		menuItem_mc = target.attachMovie ("item_mc", "menuItem_mc" + depth, depth, {_x:xPos, _y:yPos});
		// set instance vars
		this.menuItem_mc = menuItem_mc;
		this.menuItem_mc.classInstance = "menu" + depth;
		// call methods
		setLabel (menuLabel);
		setHighlight (false);
		setOnPress ();
	}
	/**
	 * setLabel method
	 * 
	 * @param label	the text string we want to display
	 */
	private function setLabel (menuLabel:String):Void {
		menuItem_mc.label_txt.text = menuLabel;
	}
	/**
	 * onPress method
	 * 
	 */
	private function setOnPress ():Void {
		menuItem_mc.onPress = function ():Void  {
			this._parent[classInstance].eventCall ();
		};
	}
	/**
	 * eventCall method
	 * 
	 */
	public function eventCall ():Void {
		// should be overwritten with specific event
		trace ("The eventCall() method in MenuItem.as was called. Override this method to handle menu item selections for your application.");
	}
	/**
	  * destroyViewer method
	  */
	public function destroyViewer ():Void {
		viewer.destroy ();
		delete viewer;
	}
	/**
	 * setHightlight method
	 * 
	 * @param state	turn the movieClip _visible property to 1 or 0
	 */
	public function setHighlight (state:Boolean):Void {
		menuItem_mc.highlight_mc._visible = state;
	}
	/**
	 * enableClip method
	 * 
	 * @param state	enable or disable the item
	 */
	public function enableClip (state:Boolean):Void {
		menuItem_mc.enabled = state;
	}
}
